On the VDoc Platform, the users input are validated on the server-side. The field value is being sent to the server and if the validation fails, the response is sent back to the client and a feedback is shown underneath the field.
The VDoc development kit provides a new Framework to develop classes for validating user's input on the server-side.
The Validator Framework gives a standard way for defining :
The XML validator file should be deployed on the custom/validators folder. Its name must be unique on the VDoc server. To prevent name conflicts it is recommended to use the following template: companyName-validators.xml (e.i. vdoc-validators.xml). This XML definition file provides all the necessary information to describe several validators:
Error during retrieving content skip as ignoreDownloadError activated.
A runtime class is a Java class which will be called by the framework when the UI Framework validates any form fields. A runtime class must extend the com.axemble.vdoc.sdk.validators.BaseValidator<T> class. The BaseValidator class uses a generic to validate any kind of object.
By creating a validator runtime class you need to implement two methods:
Another method could be overridden:
package com.axemble.vdoc.education.validators; import java.util.List; import org.apache.commons.lang.StringUtils; import com.axemble.vdoc.sdk.validators.BaseValidator; public class DemoValidator extends BaseValidator<String> { @Override public boolean validate( String object, List<String> parameters ) { if ( parameters != null && parameters.size() > 0 ) { String arg = parameters.get( 0 ); // checks if the 'arg' parameter is contained within the 'object' boolean ignoreCase = parameters.size() > 1 && parameters.get( parameters.size() - 1 ).equalsIgnoreCase( "--ignorecase" ); return ( StringUtils.isNotEmpty( object ) && StringUtils.isNotEmpty( arg ) && ( ignoreCase ? ( object.toLowerCase().indexOf( arg.toLowerCase() ) != -1 ) : ( object.indexOf( arg ) != -1 ) ) ); } return false; } @Override public String getErrorMessage() { return getStaticString( "LG_DEMO_ERROR_MESSAGE" ); } }
The VDoc Platform has a wide range of validation functions. Designers can change the default validation behavior by specifying a list of rules on each input field through the property panel within the Form Designer.
Name | Description | Attributes |
alphanumeric | The input requires an answer that contains only letters a-z and numbers | alphanumeric |
alpha | The input requires an answer that contains only letters a-z | alpha |
capitalize | The input requires an answer that starts with upper case character | capitalize |
The input requires an answer that contains matches the email format | ||
url | The input requires an answer that contains matches the url format | url |
maxchars | The input checks that contains more than maxchars characters | maxchars number_of_characters |
minchars | The input checks that contains less than minchars characters | minchars number_of_characters |
contains | The input checks that the answer contains the specified text | contains text --ignorecase |
startswith | The input checks that the answer starts with the text | startswith text --ignorecase |
endswith | The input checks that the answer ends with the text | endswith text --ignorecase |
lowercase | The input requires an answer with only lower case characters | lowercase |
uppercase | The input requires an answer with only upper case characters | uppercase |
sysname | The input requires an answer that matches the system name rules : - only letters a-z, A-Z, numbers or underscores - no number on first character | sysname |
extensionformat | The input checks that the answer matches the full qualified name for a class. | extensionformat |
regexp | The input checks that the answer matches the expression. Example : The following example allows only lower case letters regexp ^([a-z]+)$ | regexp expression --ignorecase --multiline |